<%-- 
    Document   : post-category
    Created on : Feb 13, 2012, 11:53:44 PM
    Author     : PhucAn
--%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Post categories</title>
        <script>
            function setValue(identifier){
                //set value for hidden field. This field hold the 'id' value of selected item                
                document.getElementById("selected-item-id").value=identifier;               
            }
            
        </script>
    </head>
    <body>
        <form method="post" action="PostsCategoryAction.do?method=delete">
            <table class="data-table">
                <tr>
                    <th>Name</th>
                    <th>Parent_id</th>
                    <th></th>
                    <th></th>
                </tr>
                <c:forEach var="cate" items="${list}">
                <tr>
                    <td>${cate.name}</td>
                    <td>${cate.parentId}</td>
                    <td><a href="?pcontent=post-category&cateid=${cate.id}">Add post</a></td>
                    <td><input type="button" name="set-value" value="Delete" onclick='showConfirm();setValue(${cate.id});'/></td>
                </tr> 
                </c:forEach>
            </table>
            <input type="hidden" id="selected-item-id" name="selected-item-id" value=""/>
            <div class="confirm-box">
                <div>Are you sure want to continue?</div>
                <input type="submit" name="remove" onclick="hideConfirm();" value="Delete"/>
                <input type="button" value="Cancel"/>
            </div>
        </form>
        <form method="post" action="PostsCategoryAction.do?method=create">
            <table class="form-table">
                <tr>
                    <td>Post name:</td>
                    <td><input type="text" name="name"/></td>
                    <td></td>
                </tr>
                <tr>
                    <td>Parent_id: </td>
                    <td><input type="text" name="parent-id"/></td>
                    <td></td>
                </tr>
                <tr>
                    <td></td>
                    <td colspan="2"><input type="submit" name="add" value="Create"/></td>
                </tr>
            </table>                
        </form>

    </body>
</html>













